package com.briup.product_my.controller;

import com.briup.product_my.domain.ManagerFenceHouse;
import com.briup.product_my.domain.QuarantineRegistration;
import com.briup.product_my.result.Result;
import com.briup.product_my.service.QuarantineRegistrationService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther: xiongwenbin
 * @Date: 2024/8/22-08-22-下午2:37
 * @Description: com.briup.product_my.controller
 */
@RestController
@Api(tags = "病原检验登记模块")
@RequestMapping("/quarantineRegistration")
public class QuarantineRegistrationController {
    @Autowired
    private QuarantineRegistrationService quarantineRegistrationService;

    @PostMapping("/saveOrUpdate")
    @ApiOperation(value ="病原检验登记保存或更新",notes = "如果id为空，则为新增，否则为更新")
    public Result saveOrUpdate(@RequestBody QuarantineRegistration quarantineRegistration){
        quarantineRegistrationService.saveOrUpdate(quarantineRegistration);
        return Result.success();
    }
    @ApiOperation(value = "条件查询检疫信息")
    @GetMapping
    public Result getFenceHouse(@RequestParam(value = "bQualified",required = false) String bQualified,@RequestParam(value = "grMechanism",required = false) String grMechanism, @RequestParam(value = "name",required = false) String name, @RequestParam(value = "pageNum",required = false) Integer pageNum, @RequestParam(value = "pageSize",required = false) Integer pageSize){
        PageInfo<QuarantineRegistration> result = quarantineRegistrationService.findAll(pageNum,pageSize,bQualified,grMechanism);
        return Result.success(result);
    }
    @DeleteMapping("/deleteById/{id}")
    @ApiOperation(value = "根据id删除")
    public Result delete(@PathVariable("id") Integer id){
        quarantineRegistrationService.delete(id);
        return Result.success();
    }
    @DeleteMapping("/deleteByIdAll")
    @ApiOperation(value = "批量删除")
    public Result deleteByIdAll(@RequestBody Integer[] ids){
        quarantineRegistrationService.deleteByIdAll(ids);
        return Result.success();
    }
}
